// 默认数据
const defaultState = {
  guideStep: 1, // 引导步骤
  guided: window.localStorage.guided === '1' ? true : false, // 是否已完成引导
  globalData: {}, // 全局数据
}

export default (state = defaultState, action) => {

  // 删除一条数据
  if (action.type === 'globalData' ) {
    let newState = state
    newState.globalData = action.value
    return newState
  }

  // 引导下一步
  if (action.type === 'guideTheNextStep' ) {
    let newState = state
    newState.guideStep++
    return newState
  }

  // 完成引导
  if (action.type === 'accomplishGuide' ) {
    let newState = state
    newState.guideStep = 1
    newState.guided = true
    window.localStorage.guided = '1'
    return newState
  }

  // 重置引导
  if (action.type === 'resetGuide' ) {
    let newState = state
    newState.guideStep = 1
    newState.guided = false
    window.localStorage.removeItem('guided')
    return newState
  }

  return state
}